//
//  CMThemeSettings.swift
//  covermedia
//
//  Created by Travel on 16/1/20.
//  Copyright © 2016年 covermedia. All rights reserved.
//

import Foundation
import UIKit

public enum CMReadStyle: Int {
    case day = 0
    case night
}

public enum CMFontSize : Int {
    case xxxl = 70 //用于新闻详情标题
    case xxl = 60
    case xl = 54
    case xl_reduce = 51
    case l = 48
    case l_reduce = 42
    case m = 40
    case s = 33
    case xs = 30
    
    public var fontSize: CGFloat {
        return rawValue.pixel
    }
}


public enum CMCommonColor {
    case green
    case blue
    case yellow
    case red
}

public struct CMThemeSettings {

    public static func commonColor(_ color: CMCommonColor, alpha: Float = 1.0) -> UIColor {
        var realColor: UIColor
        switch (color) {
        case .green:
            realColor = UIColor.cm_colorWithHex(0x5cc21e, alpha: alpha)
        case .blue:
            realColor = UIColor.cm_colorWithHex(0x5a89fa, alpha: alpha)
        case .yellow:
            realColor = UIColor.cm_colorWithHex(0xf78826, alpha: alpha)
        case .red:
            realColor = UIColor.cm_colorWithHex(0xff0000, alpha: alpha)
        }
        return realColor
    }
    
    
    /**
     基础颜色设置
     
     - parameter mode: 白天黑夜模式
     - parameter type: 组件类型 ps: 通用类型查找UI规格，特定类型可扩展

     - returns: 颜色
     */
    public static func basicColor(_ mode: CMReadStyle, basicType type: CMThemeWidgetType) -> UIColor {
        switch (mode, type) {
            
        case (.day, .b1):
            return UIColor.cm_colorWithHex(0x333333)
        case (.night, .b1):
            return UIColor.cm_colorWithHex(0xffffff)
        case (.day, .b2):
            return UIColor.cm_colorWithHex(0x474747)
        case (.night, .b2):
            return UIColor.cm_colorWithHex(0xffffff, alpha: Float(0xcc)/255)
        case (.day, .b3):
            return UIColor.cm_colorWithHex(0x757575)
        case (.night, .b3):
            return UIColor.cm_colorWithHex(0xffffff, alpha: Float(0x99)/255)
        case (.day, .b4):
            return UIColor.cm_colorWithHex(0xa3a3a3)
        case (.night, .b4):
            return UIColor.cm_colorWithHex(0xffffff, alpha: Float(0x66)/255)
        
        case (.day, .g):
            return UIColor.white
        case (.night, .g):
            return UIColor.black
        case (.day, .g0):
            return UIColor.cm_colorWithHex(0xeeeeee)
        case (.night, .g0):
            return UIColor.cm_colorWithHex(0x000000)
        case (_, .g1):
            return UIColor.cm_colorWithHex(0xcccccc)
        case (.day, .g2):
            return UIColor.cm_colorWithHex(0xeaeaea)
        case (.night, .g2):
            return UIColor.cm_colorWithHex(0xeaeaea, alpha: Float(0x1a)/255)
        case (.day, .g3):
            return UIColor.cm_colorWithHex(0xfefefe)
        case (.night, .g3):
            return UIColor.cm_colorWithHex(0x303030)
        case (.day, .g4):
            return UIColor.cm_colorWithHex(0xf8f8f8)
        case (.night, .g4):
            return UIColor.cm_colorWithHex(0x191919)
        case (.day, .g5):
            return UIColor.cm_colorWithHex(0xf8f8f8)
        case (.night, .g5):
            return UIColor.cm_colorWithHex(0x191919)
        case (.day, .g6):
            return UIColor.cm_colorWithHex(0xfafafa)
        case (.night, .g6):
            return UIColor.cm_colorWithHex(0x474747)
        case (.day, .g7):
            return UIColor.cm_colorWithHex(0xffffff, alpha: Float(0x99)/255)
        case (.night, .g7):
            return UIColor.cm_colorWithHex(0x000000, alpha: Float(0x1f)/255)
        case (.day, .g8):
            return UIColor.cm_colorWithHex(0xf5f3f4)
        case (.night, .g8):
            return UIColor.cm_colorWithHex(0x5b5b5b)
        
        case (_, .textfieldSeparator):
            return UIColor.cm_colorWithHex(0xe0e0e0)
            
        case (.day, .tableViewBackGround):
            return UIColor.cm_colorWithHex(0xededed)
        case (.night, .tableViewBackGround):
            return UIColor.cm_colorWithHex(0x303030)
            
//        case (_, .r1):
//            return UIColor.cm_colorWithHex(0xf0523f)
//        case (_, .r2):
//            return UIColor.cm_colorWithHex(0xe64532)
//        case (_, .r3):
//            return UIColor.cm_colorWithHex(0xf74e40)
//        case (_, .r4):
//            return UIColor.cm_colorWithHex(0xfff0ee)
        case (_, .r5):
            return UIColor.cm_colorWithHex(0xe62f17)
            
        case (_,.inputCursor):
            return UIColor.cm_colorWithHex(0x5a89fa)
        case (_,.textField_Text_Color):
            return UIColor.cm_colorWithHex(0x474747)
        case (_,.textField_Text_Placeholder_Color):
            return UIColor.cm_colorWithHex(0xcccccc)
        case (_,.textField_Unclickable_Color):
            return UIColor.cm_colorWithHex(0xe0e0e0)
        case (_,.textField_Separator):
            return UIColor.cm_colorWithHex(0xe0e0e0)
        case (_,.slider):
            return UIColor.cm_colorWithHex(0xf0523f)
            
        case (.day, .nav):
            return UIColor.cm_colorWithHex(0xf8f8f8)
        case (.night, .nav):
            return UIColor.cm_colorWithHex(0x474747)
        case (.day, .tab):
            return UIColor.cm_colorWithHex(0xf8f8f8)
        case (.night, .tab):
            return UIColor.cm_colorWithHex(0x474747)
            
            
        case (_, .cover_Green):
            return UIColor.cm_colorWithHex(0x66d24f)
        case (_, .coverGreenTagTop):
            return UIColor.cm_colorWithHex(0x6fe054)
        case (_, .coverGreenTagBottom):
            return UIColor.cm_colorWithHex(0x61ca4c)
            

        case (_, .cover_Purple):
            return UIColor.cm_colorWithHex(0x8b62f7)
        case (_, .coverPurpleTagTop):
            return UIColor.cm_colorWithHex(0xaf85fc)
        case (_, .coverPurpleTagBottom):
            return UIColor.cm_colorWithHex(0x835bf6)

        case (_, .cover_Blue):
            return UIColor.cm_colorWithHex(0x198fe5)
        case (_, .coverBlueTagTop):
            return UIColor.cm_colorWithHex(0x63b1fc)
        case (_, .coverBlueTagBottom):
            return UIColor.cm_colorWithHex(0x1499f7)
            
        case (_, .channelNav):
            return UIColor.cm_colorWithHex(0xe62f17)
//        default:
//            fatalError("请扩展额外的颜色设置")
        }
    }
}


public enum CMThemeWidgetType {
    case b1
    case b2
    case b3
    case b4 
    
    case g
    case g0
    case g1
    case g2
    case g3
    case g4
    case g5
    case g6
    case g7
    case g8
    
    case textfieldSeparator
    case tableViewBackGround
    
//    case r1
//    case r2
//    case r3
//    case r4
    case r5
    
    case inputCursor
    case textField_Text_Color
    case textField_Text_Placeholder_Color
    case textField_Unclickable_Color
    case textField_Separator
    case slider
    
    case cover_Green
    case coverGreenTagTop
    case coverGreenTagBottom
    
    case cover_Purple
    case coverPurpleTagTop
    case coverPurpleTagBottom

    case cover_Blue
    case coverBlueTagTop
    case coverBlueTagBottom
    
    case nav
    case tab
    
    case channelNav
}











